<?php

include '../helpers/application.php';
include '../helpers/dbhelper.php';
include '../helpers/userhelper.php';

$app = new Application();

if(isset($_POST)) {

	$type = substr($_POST['id'], 0, 1);
	$id = substr($_POST['id'], 1);
	$value = utf8_decode($_POST['value']);

	switch ($type) {
		case "v": $app->db->query("UPDATE vorlesungen SET vorlesungsname = '$value' WHERE VORLESUNGSID = $id"); break;
		case "s": $app->db->query("UPDATE studienfach SET studienfachname = '$value' WHERE STUDIENFACHID = $id"); break;
	}

	print utf8_encode($value);
}

?>